package com.example.lifecycledemo;

import android.app.Activity;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

/**
 * @author: tuyrt7 on 2020/8/28.
 * Describe:
 */
public class LocationListener implements LifecycleObserver {

    private Activity mContext;
    private onLocationChangeListener mListener;

    public LocationListener(Activity context , onLocationChangeListener listener) {
        mContext = context;
        mListener = listener;

        initLocationManager();
    }

    private void initLocationManager() {
        //初始化操作
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    private void startGetLocation() {
        //开始

        //更新数据
        mListener.onChange(1.0, 1.0);
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    private void stopGetLocation() {
        //停止
        mListener.onChange(2.0, 2.0);
    }


    interface onLocationChangeListener {
        void onChange(double latitude, double longitude);
    }
}

